﻿Namespace ServerSwitcher

    Public Module mServerSwitcher

        Public Sub PacketArrival(ByRef info As EvoLib.Protocol.Packet, ByRef struct() As Byte)

            Select Case CType(info.PacketType, EvoLib.Protocol.LoginPacketType)

                Case EvoLib.Protocol.LoginPacketType.TryLogin
                    Select Case info.PacketOpCode

                        Case EvoLib.Protocol.PacketOpCode.Acknowledge
                            MessageBoxes.RemoveStateNotice()
                            MessageBoxes.SetStateNotice("Selecting Character...")
                            System.Threading.Thread.Sleep(250)
                            System.Windows.Forms.Application.DoEvents()

                    End Select

                Case EvoLib.Protocol.LoginPacketType.TrySelectChar
                    Select Case info.PacketOpCode

                        Case EvoLib.Protocol.PacketOpCode.Acknowledge
                            MessageBoxes.RemoveStateNotice()
                            MessageBoxes.SetStateNotice("Loading Map...")
                            System.Threading.Thread.Sleep(250)
                            System.Windows.Forms.Application.DoEvents()

                            Dim startinfo As Protocol.StartInfo = Protocol.Functions.ArrayToStruct(struct, GetType(Protocol.StartInfo))

                            MiniMap.CurrentFmmapIndex = startinfo.LoadMapInfo.Fmmap_Index

                            GameWindow.LoadMap(startinfo.LoadMapInfo.Posinfo.STR_MAP)

                            GameWindow.mCurrentMapName = startinfo.LoadMapInfo.STR_MAPNAME
                            GameWindow.CoordX = startinfo.LoadMapInfo.Posinfo.INT2_X
                            GameWindow.CoordY = startinfo.LoadMapInfo.Posinfo.INT2_Y

                            Player.ShapeInfo = startinfo.ShapeInfo
                            Player.VitalPoints = startinfo.VitalPoints

                            Game.Init()
                            'Globals.gGameState = Globals.GameState.Game

                    End Select



            End Select

        End Sub

    End Module

End Namespace